package com.java01.misc.xml;

import java.util.Iterator;

import net.n3.nanoxml.IXMLElement;
import net.n3.nanoxml.IXMLParser;
import net.n3.nanoxml.StdXMLReader;
import net.n3.nanoxml.XMLParserFactory;

public class NanoXMLParser3 {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws Exception{
		IXMLParser parser = XMLParserFactory.createDefaultXMLParser();

		String xmlString = "<XML><NAME>atoo</NAME><WEBSITE>www.java01.com</WEBSITE></XML>";
		parser.setReader(StdXMLReader.stringReader(xmlString));
	
		IXMLElement xml = (IXMLElement) parser.parse();

		Iterator<IXMLElement> it=xml.getChildren().iterator();
		while(it.hasNext()){
			IXMLElement child=it.next();
			System.out.println(String.format("%1$s => %2$s", child.getName(),child.getContent()));
		}
	}
}